﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class UserControl_TopSearchBusiness : System.Web.UI.UserControl
{
    security baomat = new security();
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            using (Up1VNDataContext dc = new Up1VNDataContext())
            {
                var Topview = (from o in dc.EStores 
                               join u in dc.Users on o.Users_Id equals u.Users_Id
                               orderby o.EStore_View 
                               select new {
                                o.EStore_MobilePhone,
                                o.EStore_Id,
                                o.EStore_Name,
                                o.Estore_HomePhone,
                                o.EStore_Logo,
                                u.Users_Email
                               }).Take(18).ToList();
                if (Topview.Count > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var item in Topview)
                    {
                        sb.Append("<div class='content_panels'>");
                        string logo = (item.EStore_Logo != null) ? ResolveUrl("~/User/avatar/" + item.EStore_Logo) : ResolveUrl("~/images/logo_box.jpg");
                        sb.Append("<a href='" + ResolveUrl("~/" + baomat.RemoveSpecialCharacter(item.EStore_Name).Replace(" ", "-").ToLower() + "/Thongtindoanhnghiep.html") + "'><img src='" + logo + "' alt='" + item.EStore_Name + "' title='" + item.EStore_Name + "' align='left' /></a>");
                        sb.Append("<h4><a href='" + ResolveUrl("~/" + baomat.RemoveSpecialCharacter(item.EStore_Name).Replace(" ", "-").ToLower() + "/Thongtindoanhnghiep.html") + "'>" + item.EStore_Name + "</a><br /></h4>");
                        sb.Append("<h5>[P] "+item.Estore_HomePhone+"<br />[M] "+item.EStore_MobilePhone+"<br />[E] "+item.Users_Email+"</h5>");
                        sb.Append("<br class='clear' />");
                        sb.Append("</div>");
                    }
                    ltrTopsearch.Text = sb.ToString();
                }
            }
        }
        catch (Exception ex)
        {
        }
    }
}